package com.aron;

import com.utils.ImageUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;


/**
 * @version v1.0
 * @ProjectName: studycoding
 * @ClassName: ResourseMgr
 * @Description: TODO(静态资源，只会加载一次,将资源合理的加载在项目中)
 * @Author: Leo
 * @Date: 2020/6/13 9:34
 */
public class ResourseMgr {

    private Logger logger= LoggerFactory.getLogger(ResourseMgr.class);
    //玩家
    public static BufferedImage playerTankL,playerTankU,playerTankR,playerTankD;
    //敌人
    public static BufferedImage enemyTankL,enemyTankU,enemyTankR,enemyTankD;
    //导弹
    public static BufferedImage tankMissile,enemyMissile;

    //坦克爆炸
    public static BufferedImage[] tankBlasts=new BufferedImage[8];

    static {
        try {

            //玩家tank
            playerTankU= ImageIO.read(ResourseMgr.class.getClassLoader().getResourceAsStream("images/p1tankU.gif"));
            playerTankL= ImageUtil.rotateImage(playerTankU,-90);
            playerTankR= ImageUtil.rotateImage(playerTankU,90);
            playerTankD= ImageUtil.rotateImage(playerTankU,180);

            //敌人tank
            enemyTankU= ImageIO.read(ResourseMgr.class.getClassLoader().getResourceAsStream("images/enemy1U.gif"));
            enemyTankL= ImageUtil.rotateImage(enemyTankU,-90);
            enemyTankR= ImageUtil.rotateImage(enemyTankU,90);
            enemyTankD= ImageUtil.rotateImage(enemyTankU,180);

            //玩家导弹
            tankMissile=ImageIO.read(ResourseMgr.class.getClassLoader().getResourceAsStream("images/tankmissile.gif"));
            enemyMissile=ImageIO.read(ResourseMgr.class.getClassLoader().getResourceAsStream("images/enemymissile.gif"));

            for (int i = 0; i < 8; i++)
               tankBlasts[i]=ImageIO.read(ResourseMgr.class.getClassLoader().getResourceAsStream("images/blast"+(i+1)+".gif"));
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
